<?php
/**
 *  MyApp_ViewClass.php
 *
 *  @author     {$author}
 *  @package    Smscom
 */

require_once 'MyApp_ViewClass_Base.php';
/**
 *
 *  @package    Smscom
 *  @access     public
 */
class MyApp_ViewClass extends MyApp_ViewClass_Base
{
    /**
     *
     *  @access protected
     */
    function _setDefault(&$renderer)
    {
        parent::_setDefault($renderer);
    }
    
    /**
     *
     *  @access protected
     *  @param  string  $title   タイトル
     */
    function _setPageTitle($title, $titlePage = false, $pageNo = false)
    {
        $site_name = $this->config->get('site_name_long');
        if ($titlePage) {
            $title = Smscom_Util::formatPageTitle($title);
            if($pageNo < 2) {
                $title = empty($title) ? "- {$titlePage} -" : "{$title} - {$titlePage} -";
            } else {
                $title = empty($title) ? "{$pageNo}page - {$titlePage} -" : "{$title} {$pageNo}page - {$titlePage} -";
            }
        } else {
            $title = empty($title) ? $site_name : "{$title} - {$site_name}";
        }
        $this->af->setApp('page_title', $title);
    }
    
    /**
     *
     *  @access protected
     *  @param  string  $keyword
     */
    function _setPageKeyword($keyword)
    {
        $base_keyword = $this->config->get('meta_keyword');
        $keyword = empty($keyword) ? $base_keyword : $keyword;
        $this->af->setApp('page_keyword', $keyword);
    }
    
    /**
     *
     *  @access protected
     *  @param  string  $desc   説明
     */
    function _setPageDesc($desc, $limitChar = false, $pageNo = false)
    {
        $default_desc = $this->config->get('meta_description');
        if ($limitChar) {
            $desc = Smscom_Util::formatDescripton($desc);
            if($pageNo > 1) {
                $descPageNo = $pageNo."page ".$desc;
                $strDescPageNo = (mb_strlen($descPageNo)>$limitChar) ? '...' : '';
                $limitDescPageNo = mb_substr($descPageNo, 0, $limitChar, 'UTF-8'). $strDescPageNo;
                $desc = empty($desc) ? $default_desc : $limitDescPageNo;
            } else {
                $strDesc = (mb_strlen($desc)>$limitChar) ? '...' : '';
                $limitDesc = mb_substr($desc, 0, $limitChar, 'UTF-8'). $strDesc;
                $desc = empty($desc) ? $default_desc : $limitDesc;
            }
        } else {
            $desc = empty($desc) ? $default_desc : $desc;
        }
        $this->af->setApp('page_desc', $desc);
    }
    /**
     *  JavaScript
     *
     *  @access protected
     *  @param  string
     */
    function _setJavascript($url)
    {
        static $i;
        static $ar;

        if (!isset($i)) {
            $i = 0;
        }

        if (!is_array($ar)) {
            $ar = array();
        }

        $ar[$i]['url'] = $url;
        $i++;

        $this->af->setApp('javascript', $ar);
    }

    /**
     *
     *  @access protected
     *  @param  string
     */
    function _setCSS($url)
    {
        static $ar;

        if (!is_array($ar)) {
            $ar = array();
        }

        $ar[]['url'] = $url;

        $this->af->setApp('css', $ar);
    }
    

    /**
     *
     *  @access protected
     */
    function _setLoginVars()
    {
        $this->_setPageTitle('ログイン');
        $this->_setPageDesc('ログイン');
        $this->_setH1('ログイン');
        $this->_setPkz('', 'ログイン');

        $this->af->setApp('contents_title', 'ログイン');
        $this->af->setApp('contents_title_image', 'ico_login.gif');

        $this->af->setApp('epsilon', 'login/epsilon/login.tpl');
    }
}
?>
